package com.knife.easyexcel.read.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * excel导入时的上下文信息
 *
 * @author Win10
 * @created 2024年12月19日 星期四 10:10
 */
public class ImportValidatorContext<T> {
    /**
     * 原数据
     */
    private List<T> sourceDataList;
    /**
     * 过滤器链全局缓存
     */
    private Map<String, Object> chainCache;
    /**
     * 校验缓存,存在于单条数据中
     */
    private Map<String, Object> validatorCache;
    /**
     * 已经完成链路校验了的数据
     */
    private List<ImportDataWarp<T>> alreadyValidatedImportDataWarpList;


    public ImportValidatorContext(List<T> sourceDataList) {
        this.sourceDataList = sourceDataList;
        this.alreadyValidatedImportDataWarpList = new ArrayList<>();
        this.chainCache = new HashMap<>(12);
        this.validatorCache = new HashMap<>(12);
    }

    public List<T> getSourceDataList() {
        return sourceDataList;
    }

    public Map<String, Object> getChainCache() {
        return chainCache;
    }

    public Map<String, Object> getValidatorCache() {
        return validatorCache;
    }

    public List<ImportDataWarp<T>> getAlreadyValidatedImportDataWarpList() {
        return alreadyValidatedImportDataWarpList;
    }


    public void clearChainCache() {
        chainCache.clear();
    }
}
